package com.deltapunkt.proxy.main;

import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import com.deltapunkt.proxy.AsyncServer;
import com.deltapunkt.proxy.TaskScheduler;
import com.deltapunkt.proxy.factory.ProxyFactory;

public class ServerSideMain {
	private static void startForwardProxy(ForwardPair fp) throws IOException {
		Executor exec = Executors.newSingleThreadExecutor(); // page 119
		TaskScheduler scheduler = new TaskScheduler(10);
		ProxyFactory proxyFactory = ProxyFactory.forServerAuthPortForward(fp
				.getDstAddr());
		AsyncServer server = new AsyncServer(scheduler, proxyFactory,
				fp.getSrcAddr());

		exec.execute(server);
	}

	public static void main(String[] args) throws IOException {
		ForwardPair fp = new ForwardPair("", 32767, "127.0.0.1", 1433);
		startForwardProxy(fp);
	}
}
